#include <bits/stdc++.h>

using namespace std;

struct node
{
    char v;
    int cnt;
    unordered_map<char, node *> next;
    node(char a)
    {
        v = a, cnt = 0;
    }
};

int n, cnt = 0;
bool order[30001];
string input[30001];

bool hasCycle(unordered_map<char, unordered_multiset<char>> &graph)
{
    unordered_map<char, int> inDegree;
    queue<char> q;
    vector<char> topoOrder;

    // 初始化每个节点的入度
    for (const auto &node : graph)
    {
        if (inDegree.find(node.first) == inDegree.end())
            inDegree[node.first] = 0;
        for (char neighbor : node.second)
            inDegree[neighbor]++;
    }

    // 将入度为0的节点入队
    for (const auto &node : inDegree)
        if (node.second == 0)
            q.push(node.first);

    // 进行拓扑排序
    while (!q.empty())
    {
        char current = q.front();
        q.pop();
        topoOrder.push_back(current);
        if (graph.count(current) == 0)
            continue;

        for (char neighbor : graph[current])
            if (--inDegree[neighbor] == 0)
                q.push(neighbor);
    }

    return topoOrder.size() != inDegree.size();
}

/**
 * @brief 深度优先搜索函数，用于遍历树并检查是否存在环
 *
 * @param root 当前节点指针
 * @param m 字符到其邻居集合的映射
 */
void dfs(node *root, unordered_map<char, unordered_multiset<char>> &m)
{
    // 如果当前节点有计数（即不是根节点）
    if (root->cnt)
    {
        bool f = !hasCycle(m);
        order[root->cnt] = f, cnt += f;
        return;
    }
    // 遍历当前节点的所有子节点
    for (auto i : root->next)
    {
        for (auto j : root->next)
            m[i.second->v].insert(j.second->v);
        m[i.second->v].erase(m[i.second->v].find(i.second->v));
        dfs(i.second, m);
        for (auto j : root->next)
            if (j.second->v != i.second->v)
                m[i.second->v].erase(m[i.second->v].find(j.second->v));
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    node *tree = new node(' ');
    node *q = tree;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> input[i];
        q = tree;
        for (int j = 0; j < input[i].size(); j++)
        {
            if (q->next[input[i][j]])
                q = q->next[input[i][j]];
            else
                q->next[input[i][j]] = new node(input[i][j]), q = q->next[input[i][j]];
        }
        q->cnt = i;
    }
    unordered_map<char, unordered_multiset<char>> um;
    dfs(tree, um);
    cout << cnt << endl;
    for (int i = 1; i <= n; i++)
        cout << (order[i] ? input[i] + "\n" : "");
    return 0;
}

